 

#import "BNDSLNavigationBarConfigure.h"
#import "UIViewController+BNDSLCategory.h"

@interface BNDSLNavigationBarConfigure()

@property (nonatomic, assign) CGFloat navItemLeftSpace;
@property (nonatomic, assign) CGFloat navItemRightSpace;

@end

@implementation BNDSLNavigationBarConfigure

static BNDSLNavigationBarConfigure *instance = nil;

+ (instancetype)sharedInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [BNDSLNavigationBarConfigure new];
    });
    return instance;
}

// 设置默认的导航栏外观
- (void)setupDefaultConfigure {
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.titleColor      = [UIColor blackColor];
    
    self.titleFont       = [UIFont boldSystemFontOfSize:17.0];
    
    self.statusBarHidden = NO;
    
    self.statusBarStyle  = UIStatusBarStyleDefault;
    
    self.backStyle       = BNDSLNavigationBarBackStyleBlack;
    
    self.sl_navItemLeftSpace    = 0;
    self.sl_navItemRightSpace   = 0;
    
    self.navItemLeftSpace       = 0;
    self.navItemRightSpace      = 0;
    
    self.sl_pushTransitionCriticalValue = 0.3;
    self.sl_popTransitionCriticalValue  = 0.5;
    
    self.sl_translationX = 5.0f;
    self.sl_translationY = 5.0f;
    self.sl_scaleX = 0.95;
    self.sl_scaleY = 0.97;
}

 
- (void)setSl_navItemLeftSpace:(CGFloat)sl_navItemLeftSpace{
    _sl_navItemLeftSpace = sl_navItemLeftSpace;
}

- (void)setSl_navItemRightSpace:(CGFloat)sl_navItemRightSpace {
    _sl_navItemRightSpace = sl_navItemRightSpace;
}

- (void)setupCustomConfigure:(void (^)(BNDSLNavigationBarConfigure *))block {
    [self setupDefaultConfigure];
    
    !block ? : block(self);
    
    self.navItemLeftSpace  = self.sl_navItemLeftSpace;
    self.navItemRightSpace = self.sl_navItemRightSpace;
}

// 更新配置
- (void)updateConfigure:(void (^)(BNDSLNavigationBarConfigure *configure))block {
    !block ? : block(self);
}

- (CGFloat)sl_fixedSpace {
    CGSize screentSize = [UIScreen mainScreen].bounds.size;
    return MIN(screentSize.width, screentSize.height) > 375 ? 20 : 16;
}

@end
